/* GUI CONVERTED from ppptrp02.p (converter v1.75) Mon Jan 29 03:06:26 2001 */
/* ppptrp02.p - REORDER REPORT                                          */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* web convert ppptrp02.p (converter v1.00) Fri Oct 10 13:57:15 1997 */
/* web tag in ppptrp02.p (converter v1.00) Mon Oct 06 14:17:38 1997 */
/*F0PN*/ /*K15W*/ /*                                                    */
/*V8:ConvertMode=FullGUIReport                                 */
/* REVISION: 1.0      LAST MODIFIED: 07/17/86   BY: PML                 */
/* REVISION: 7.0      LAST MODIFIED: 09/04/91   BY: pma *F003*          */
/* REVISION: 7.0      LAST MODIFIED: 01/31/92   BY: pma *F118*          */
/* REVISION: 7.3      LAST MODIFIED: 03/19/93   BY: pma *G849*          */
/* REVISION: 7.3      LAST MODIFIED: 04/13/93   BY: pma *G949*          */
/* REVISION: 7.3      LAST MODIFIED: 06/01/93   BY: pma *GB45*          */
/* REVISION: 7.3      LAST MODIFIED: 08/27/94   BY: rxm *GL58*          */
/* REVISION: 8.5      LAST MODIFIED: 01/07/96   BY: *J1DJ* Murli Shastri*/
/* REVISION: 8.6      LAST MODIFIED: 10/24/97   BY: ckm *K15W*          */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane        */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/13/00   BY: *N0KQ* myb              */
/* REVISION: 9.1      LAST MODIFIED: 01/24/01   BY: *L17H* Vandna Rohira    */

     /* DISPLAY TITLE */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

     {mfdtitle.i "b+ "} /*GB45*/

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE ppptrp02_p_1 "Qty Open"
/* MaxLen: Comment: */

&SCOPED-DEFINE ppptrp02_p_2 "Below Safety Stock"
/* MaxLen: Comment: */

&SCOPED-DEFINE ppptrp02_p_3 "Below Reorder Point"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

         define variable abc like pt_abc.
/*G949   define variable abc1 like pt_abc.    */
         define variable part like pt_part.
         define variable part1 like pt_part.
         define variable line like pt_prod_line.
         define variable line1 like pt_prod_line.
         define variable vend like pt_vend.
         define variable vend1 like pt_vend.
         define variable vendor like pt_vend.
         define variable qty_open like pod_qty_ord label {&ppptrp02_p_1}.
         define variable below_rop like mfc_logical initial yes  label {&ppptrp02_p_3}.
         define variable below_sfty like mfc_logical initial yes label {&ppptrp02_p_2}.
         define variable name like ad_name.
         define variable star as character format "x(3)".
         define variable skip_flag like mfc_logical.
         define variable buyer like pt_buyer.
         define variable site like in_site.
         define variable site1 like in_site.
/*F118*/ define variable rop like pt_rop.
/*F118*/ define variable sfty like pt_sfty_stk.

         /* SELECT FORM */
         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
            part           colon 25
            part1          label {t001.i} colon 52 skip
            line           colon 25
            line1          label {t001.i} colon 52 skip
            vend           colon 25
            vend1          label {t001.i} colon 52 skip
            site           colon 25
            site1          label {t001.i} colon 52 skip(1)
            buyer          colon 25
            abc            colon 25 skip
            below_rop      colon 25
            below_sfty     colon 25 skip
/*GL58      with frame a side-labels. */
/*GL58*/    SKIP(.4)  /*GUI*/
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME

            /* SET EXTERNAL LABELS */
            setFrameLabels(frame a:handle).

            /* REPORT BLOCK */

/*K15W*/    {wbrp01.i}
            
/*GUI*/ {mfguirpa.i true  "printer" 132 }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:

            if part1 = hi_char then part1 = "".
            if line1 = hi_char then line1 = "".
            if vend1 = hi_char then vend1 = "".
/*G949      if abc1 = hi_char then abc1 = "".     */
            if site1 = hi_char then site1 = "".

/*K15W*/    if c-application-mode <> 'web' then
            
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:

/*K15W*/    {wbrp06.i &command = update
              &fields = "  part part1 line line1 vend vend1 site site1 buyer abc below_rop below_sfty"
                 &frm = "a"}

/*K15W*/    if (c-application-mode <> 'web') or
/*K15W*/    (c-application-mode = 'web' and
/*K15W*/    (c-web-request begins 'data')) then do:

               bcdparm = "".
               {mfquoter.i part   }
               {mfquoter.i part1  }
               {mfquoter.i line   }
               {mfquoter.i line1  }
               {mfquoter.i vend   }
               {mfquoter.i vend1  }
               {mfquoter.i site   }
               {mfquoter.i site1  }
               {mfquoter.i buyer  }
               {mfquoter.i abc    }
               {mfquoter.i below_rop  }
               {mfquoter.i below_sfty }

               if part1 = "" then part1 = hi_char.
               if line1 = "" then line1 = hi_char.
               if vend1 = "" then vend1 = hi_char.
/*G949         if abc1 = "" then abc1 = hi_char.     */
               if site1 = "" then site1 = hi_char.

/*K15W*/    end. /* IF (c-application-mode <> 'web':u) OR */

            /* SELECT PRINTER */
            
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i  "printer" 132}
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:

            {mfphead.i}

            FORM /*GUI*/ 
               " * - " below_rop  " *** - " below_sfty
            with STREAM-IO /*GUI*/  
            frame pfoot page-bottom side-labels
            width 80. /*K15W*/

            /* SET EXTERNAL LABELS */
            setFrameLabels(frame pfoot:handle).

            view frame pfoot.

            /* FIND AND DISPLAY */

/*L17H**    for each pt_mstr where                           */
/*L17H**    (pt_prod_line >= line and pt_prod_line <= line1) */

/*L17H*/    for each pt_mstr
/*L17H*/       fields(pt_buyer    pt_cum_lead pt_desc1    pt_desc2
/*L17H*/              pt_mfg_lead pt_part     pt_pm_code  pt_prod_line
/*L17H*/              pt_pur_lead pt_rop      pt_sfty_stk pt_um
/*L17H*/              pt_vend)
/*L17H*/       where (pt_prod_line >= line and pt_prod_line <= line1)
                 and (pt_part >= part and pt_part <= part1)
/*GB45           and (pt_buyer = buyer or buyer = "")                   */
/*GB45           and (pt_vend >= vend and pt_vend <= vend1)             */
            no-lock,
/*L17H**    each in_mstr where in_part = pt_part and */
/*L17H**    (in_site >= site and in_site <= site1)   */

/*L17H*/    each in_mstr
/*L17H*/       fields(in_abc     in_avg_iss in_part in_qty_oh
/*L17H*/              in_qty_ord in_site)
/*L17H*/    where in_part   = pt_part
/*L17H*/      and (in_site >= site and in_site <= site1)
/*G949        and (in_abc  >= abc  and in_abc  <= abc1)                */
/*G949*/      and (in_abc   = abc  or  abc      = "")
/*G949        and (in_abc >= abc and in_abc <= abc1)                */
/*G949*/      and (in_abc = abc or abc = "")
            no-lock
            by pt_part by in_site with frame b down width 132 no-box:

               /* SET EXTERNAL LABELS */
               setFrameLabels(frame b:handle).

/*L17H** /*F118*/ find ptp_det where ptp_part = pt_part and ptp_site = in_site */
/*L17H** /*F118*/       no-lock no-error. */

/*L17H*/       for first ptp_det
/*L17H*/          fields(ptp_buyer   ptp_cum_lead ptp_mfg_lead ptp_part
/*L17H*/                 ptp_pm_code ptp_pur_lead ptp_rop      ptp_sfty_stk
/*L17H*/                 ptp_site    ptp_vend)
/*L17H*/          where ptp_part = pt_part and ptp_site = in_site
/*L17H*/       no-lock:
/*L17H*/       end. /* FOR FIRST ptp_det */

/*F118*/       if available ptp_det then do:
/*L17H** /*F118*/ rop = ptp_rop. */

/*L17H*/          assign
/*L17H*/             rop  = ptp_rop
/*F118*/             sfty = ptp_sfty_stk.
/*F118*/       end. /* IF AVAILABLE ptp_det */
/*F118*/       else do:

/*L17H** /*F118*/ rop = pt_rop. */
/*L17H*/          assign
/*L17H*/             rop  = pt_rop
/*F118*/             sfty = pt_sfty_stk.
/*F118*/       end. /* ELSE DO */

/*F118         if (in_qty_oh < pt_rop and below_rop = yes)         */
/*F118         or (in_qty_oh < pt_sfty_stk and below_sfty = yes)   */
/*F118*/       if
/*GB45*/          (
/*F118*/           (in_qty_oh < rop and below_rop = yes)
/*F118*/           or (in_qty_oh < sfty and below_sfty = yes)
               or (below_rop = no and below_sfty = no)
/*GB45*/          )
/*GB45*/       and (
/*GB45*/            (available ptp_det and ptp_buyer = buyer)
/*GB45*/             or (not available ptp_det and pt_buyer = buyer)
/*GB45*/             or (buyer = "")
/*GB45*/            )
/*GB45*/       and (
/*GB45*/           (available ptp_det and ptp_vend >= vend and ptp_vend <= vend1)
/*GB45*/            or (not available ptp_det and
/*GB45*/                pt_vend >= vend and pt_vend <= vend1)
/*GB45*/           )
               then do:

                  /*allow for pfoot frame*/
                  if page-size - line-counter < 4 then page.
                  star = "".
/*F118            if in_qty_oh < pt_rop then star = "  *".         */
/*F118            if in_qty_oh < pt_sfty_stk then star = "***".    */

/*F118*/          if in_qty_oh < rop then star = "  *".
/*F118*/          if in_qty_oh < sfty then star = "***".

/*J1DJ*          ** BEGIN DELETE SECTION **
.         display star no-label in_part format "X(26)" in_site
.         in_qty_oh  pt_um in_qty_ord
./*F118            pt_rop pt_sfty_stk                               */
./*F118*/          rop sfty
.             pt_pm_code pt_pur_lead
.         pt_mfg_lead  pt_cum_lead  in_avg_iss
./*G949*/          in_abc
.         with frame b.
**J1DJ*           ** END DELETE SECTION **/

/*J1DJ*           BEGIN ADD SECTION */
                  if available ptp_det then
                     display 
                          star no-label 
                          in_part format "X(26)" 
                          in_site
                          in_qty_oh  
                          pt_um 
                          in_qty_ord 
                          rop 
                          sfty
                          ptp_pm_code  @ pt_pm_code
                          ptp_pur_lead @ pt_pur_lead
                          ptp_mfg_lead @ pt_mfg_lead
                          ptp_cum_lead @ pt_cum_lead
                          in_avg_iss in_abc
                     with frame b STREAM-IO /*GUI*/ .
                  else
                     display 
                          star no-label 
                          in_part format "X(26)" 
                          in_site
                          in_qty_oh  
                          pt_um 
                          in_qty_ord 
                          rop 
                          sfty
                          pt_pm_code  @ pt_pm_code
                          pt_pur_lead @ pt_pur_lead
                          pt_mfg_lead @ pt_mfg_lead
                          pt_cum_lead @ pt_cum_lead
                          in_avg_iss in_abc
                     with frame b STREAM-IO /*GUI*/ .
/*J1DJ*           END   ADD SECTION */

                  skip_flag = yes.

                  if pt_desc1 > "" then do:
/*                      down 1.  */
                     NAME =  pt_desc1 + pt_desc2.
                     display NAME FORMAT "X(100)" at 8 WITH STREAM-IO /*GUI*/ .
/*                     display   "  " + pt_desc1 @ in_part WITH STREAM-IO /*GUI*/ .*/
                     skip_flag = no.
                  end. /* IF pt_desc1 > "" */

/*zyf             if pt_desc2 > "" then do:
                     down 1.
                     display "  " + pt_desc2 @ in_part WITH STREAM-IO /*GUI*/ .
                     skip_flag = no.
                  end. /* IF pt_desc2 > "" */
*/
/*L17H**          for each pod_det no-lock where pod_part = in_part */

/*L17H*/          for each pod_det
/*L17H*/             fields(pod_due_date pod_nbr  pod_part   pod_qty_ord
/*L17H*/                    pod_qty_rcvd pod_site pod_so_job pod_status
/*L17H*/                    pod_type     pod_um   pod_um_conv)
/*L17H*/          where pod_part   = in_part
                  and pod_site = in_site
                  and pod_status <> "c" and pod_status <> "x"
/*L17H**          and (pod_qty_ord - pod_qty_rcvd <> 0), */
/*L17H*/          and (pod_qty_ord - pod_qty_rcvd <> 0) no-lock,

/*L17H**          each po_mstr no-lock where po_nbr = pod_nbr */
/*L17H*/          each po_mstr
/*L17H*/             fields(po_nbr po_type po_vend)
/*L17H*/          where po_nbr = pod_nbr

                  and po_type <> "B"
/*L17H*/          no-lock
                  break by pod_part by pod_nbr with width 132 frame c:

/*L17H**             qty_open = pod_qty_ord - pod_qty_rcvd. */
/*L17H**             name = "".                             */

/*L17H*/             assign
/*L17H*/                qty_open = pod_qty_ord - pod_qty_rcvd
/*L17H*/                name     = ""
                        vendor = "".
/*G849               find ad_mstr where ad_addr = vendor  */
/*L17H** /*G849*/    find ad_mstr where ad_addr = po_vend */
/*L17H**             no-lock no-error no-wait.            */

/*L17H*/             for first ad_mstr
/*L17H*/                fields(ad_addr ad_name)
/*L17H*/                where ad_addr = po_vend
/*L17H*/             no-lock:
/*L17H*/             end. /* FOR FIRST ad_mstr */

                     if available ad_mstr then name = ad_name.
                     accumulate (qty_open * pod_um_conv) (total).
                     accumulate pod_nbr(count).
                     
                     /* SET EXTERNAL LABELS */
                     setFrameLabels(frame c:handle).
                     display 
                          space(19) 
                          pod_nbr 
                          space(6) 
                          pod_so_job 
                          qty_open
                          pod_um 
                          pod_um_conv  
                          pod_type
                          pod_due_date 
                          po_vend 
                          name 
                     with frame c down width 132 STREAM-IO /*GUI*/ .
                     skip_flag = no.
                     
/*GUI*/ {mfguirex.i  "false"} /*Replace mfrpexit*/
  /*D811*/
                     if last(pod_part) and (accum count pod_nbr) > 1 then do:
                        underline qty_open with frame c.
                        display 
                             accum total (qty_open * pod_um_conv) @ qty_open 
                        with frame c STREAM-IO /*GUI*/ .
                     end. /* IF LAST(pod_part) AND ... */
                  end. /* FOR EACH pod_det */

/*L17H**          for each wo_mstr where wo_part = in_part */

/*L17H*/          for each wo_mstr
/*L17H*/             fields(wo_due_date wo_lot     wo_nbr      wo_part
/*L17H*/                    wo_qty_comp wo_qty_ord wo_qty_rjct wo_site
/*L17H*/                    wo_so_job   wo_status  wo_type)
/*L17H*/             where wo_part   = in_part
                       and wo_site   = in_site
                       and wo_status <> "P"
                       and wo_status <> "C"
                       and (wo_qty_ord - wo_qty_comp - wo_qty_rjct <> 0)
/*L17H*/               and wo_type   <> "S"
/*L17H*/               and wo_type   <> "C"

                  no-lock break by wo_part by wo_due_date with width 132
                  frame d:
                     qty_open = wo_qty_ord - wo_qty_comp - wo_qty_rjct.

                     /* SET EXTERNAL LABELS */
                     setFrameLabels(frame d:handle).

                     display 
                          space(19) 
                          wo_nbr 
                          wo_lot 
                          wo_so_job
                          qty_open 
                          wo_due_date 
                     with frame d down width 132 STREAM-IO /*GUI*/ .
                     
                     accumulate qty_open(total).
                     accumulate wo_nbr(count).
                     if last(wo_part) and (accum count wo_nbr) > 1 then do:
                        underline  qty_open with frame d.
                        display 
                             accum total qty_open @ qty_open 
                             accum count wo_nbr @ wo_nbr 
                        with frame d STREAM-IO /*GUI*/ .
                     end. /* IF LAST(wo_part) AND ... */
                     skip_flag = no.
                     
/*GUI*/ {mfguirex.i  "false"} /*Replace mfrpexit*/

                  end. /* FOR EACH wo_mstr */

/*L17H*/          for each rps_mstr
/*L17H*/             fields(rps_due_date rps_line rps_part rps_qty_comp
/*L17H*/                    rps_qty_req  rps_site)
/*L17H*/             where rps_part = pt_part
/*L17H*/             and   rps_site = in_site
/*L17H*/             and rps_qty_req > rps_qty_comp
/*L17H*/          no-lock break by rps_line by rps_due_date with width 132:

/*L17H*/             qty_open = rps_qty_req - rps_qty_comp.
/*L17H*/             display 
                          space(19) 
                          rps_line 
                          space(29) 
                          qty_open
/*L17H*/                  rps_due_date 
                     with frame e down width 132 STREAM-IO /*GUI*/ .
/*L17H*/             accumulate qty_open(total).
/*L17H*/             accumulate rps_line(count).
/*L17H*/             if last(rps_line) and (accum count rps_line) > 1 then do:
/*L17H*/                underline  qty_open with frame e.
/*L17H*/                display 
                             accum total qty_open @ qty_open 
                             accum count rps_line @ rps_line
                        with frame e STREAM-IO /*GUI*/ .
/*L17H*/             end. /* IF LAST(rps_line) AND */
/*L17H*/             skip_flag = no.
/*L17H*/             
/*GUI*/ {mfguirex.i  "false"} /*Replace mfrpexit*/

/*L17H*/          end. /* FOR EACH rps_mstr */

                  if skip_flag = yes then down 1.

               end. /* IF (in_qty_oh < rop AND below_rop = YES) ... */
               
/*GUI*/        {mfguirex.i } /*Replace mfrpexit*/

            end. /* FOR EACH pt_mstr */

            /* REPORT TRAILER */
            
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


         end. /* REPEAT */

/*K15W*/ {wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" part part1 line line1 vend vend1 site site1 buyer abc below_rop below_sfty "} /*Drive the Report*/
